import Storage from '../utils/storage'
const mutations={

  // 修改用户的信息 {name nickName phone address userId}
  editUserLoginIn(state, params) {
    state.userInfo.nickName = params.nickName;
    state.userInfo.phone = params.phone;
    state.userInfo.address = params.address;
    state.userInfo.name = params.name;
    state.userInfo.userId = params.userId;
    state.isLogin = params.isLogin;
  },
  // 退出登录
  userLoginOut(state) {
    state.userInfo.nickName = '';
    state.userInfo.phone = '';
    state.userInfo.address = '';
    state.userInfo.name = '';
    state.userInfo.userId = '';
    state.isLogin = false;
    state.token = null;
    // 用户的id
    Storage.sessionRemove('price_userId');
    Storage.sessionRemove('price_userName');
    Storage.sessionRemove('price_nickName');
    Storage.sessionRemove('price_phone');
    Storage.sessionRemove('price_address');
    Storage.sessionRemove('token');
    Storage.localRemove('token');

  },
  //登录
  stateLogin(state,params) {
    state.token = params.token;
    state.isLogin = true;
    Storage.sessionSet('token',params.token);
    Storage.localSet('token',params.token);
    state.userInfo.name = params.name
  },
  // 离开首页
  leaveIndex(state,params) {
    state.isIndex = false;
  },
  // 进入首页
  enterIndex(state,params) {
    state.isIndex = true;
  },
  // 点击的蔬菜
  elickChangeVe(state,params) {
    state.ve = {
      id: params.id,
      name: params.item,
    }
  }

}
export default mutations
